//
//  MTModel.swift
//  MT
//
//  Created by zhang qiang on 2018/11/21.
//  Copyright © 2018年 张强. All rights reserved.
//

import UIKit
import ObjectMapper


/// 对应接口最外层数据类
open class BaseComponentModel: Mappable {
    /// 请求是否成功的code
    public var code: Int?
    /// 请求返回的Message
    public var message: String?
    /// 分页对象
    public var page: PageModel?
    /// 时间戳
    public var timestamp: TimeInterval?
    
    required public init?(map: Map) {
        
    }
    
    open func mapping(map: Map) {
        code    <- map["code"]
        message <- map["message"]
        page <- map["page"]
        timestamp <- map["timestamp"]
    }
}


/// 接口 data 数据 基类 不同接口请重写此类
/** 重写示例
 class Store: _Data {
     var client: String?
     var forceUpdate: Bool
     .....
 
 
     required init?(map: Map) {
        // 有默认值
        self.forceUpdate = false
        super.init(map: map)
     }
     // 具体的解析
     override func mapping(map: Map) {
         client <- map["client"]
         forceUpdate <- map["forceUpdate"]
     }
 }
 */
open class _Data: Mappable {
    
    required public init?(map: Map) {
        
    }
    
    open func mapping(map: Map) {
        
    }
}


open class PageModel: Mappable {
    
    public var curPage: Int?
    public var pageSize: Int?
    public var pages: Int?
    public var total: Int?
    
    required public init?(map: Map) {
        
    }
    
    open func mapping(map: Map) {
        curPage        <- map["curPage"]
        pageSize       <- map["pageSize"]
        pages       <- map["pages"]
        total     <- map["total"]
    }
}
